package jwdt.common.util;

import java.util.concurrent.ConcurrentMap;

import com.google.common.base.Function;
import com.google.common.collect.MapMaker;

@SuppressWarnings("rawtypes")
public class NewObjectUtil {

	public static ConcurrentMap<Class, Object> objMap = new MapMaker()
			.makeComputingMap(new Function<Class, Object>() {
				public Object apply(Class key) {
					Object obj = null;
					try {
						obj = key.newInstance();
					} catch (Exception e) {
						e.printStackTrace();
					}
					return obj;
				}
			});

	public static Object getNewObject(Class c) {
		return objMap.get(c);
	}
}
